<?php


namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class DownloadReport
{
    protected $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

    /*$('.grid-check-row').on('click', function () {

    // Your code.
    $.get('report/down?id='+$(this).data('id'),function(e){
        newwindow.location.href="http://www.cfedu.com/admin/report/down";
    });

    window.location.href="http://www.cfedu.com/admin/report/down?id="+$(this).data('id');*/
    protected function script()
    {
        return <<<SCRIPT
            o_window = function(id){
            var wi = window.open('about:blank', '_blank');
            
            
            var domain = window.location.host;
            wi.location.href = 'http://'+domain+'/admin/report/index_new?id='+id;
        };


SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

        return "<a class='fa fa-file-powerpoint-o grid-check-row' data-id='{$this->id}' onclick='o_window(".$this->id.");'></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}